﻿using PivotCollectionTools.Xml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Xml;
using System.Collections.ObjectModel;
using System;

namespace PivotCollectionTools.Xml.Test
{
    
    
    /// <summary>
    ///This is a test class for XmlNodeBaseTest and is intended
    ///to contain all XmlNodeBaseTest Unit Tests
    ///</summary>
    [TestClass()]
    public class XmlNodeBaseTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for NamespaceUri
        ///</summary>
        [TestMethod()]
        public void XmlNodeBase_NamespaceUri_Test()
        {
            Uri actual;
            actual = XmlNodeBase.NamespaceUri;
            Assert.AreEqual("http://schemas.microsoft.com/livelabs/pivot/collection/2009", actual.ToString());
        }

        /// <summary>
        ///A test for NamespacePrefix
        ///</summary>
        [TestMethod()]
        public void XmlNodeBase_NamespacePrefix_Test()
        {
            string actual;
            actual = XmlNodeBase.NamespacePrefix;
            Assert.AreEqual("p", actual);
        }

        /// <summary>
        ///A test for Extension
        ///</summary>
        [TestMethod()]
        public void XmlNodeBase_Extension_Test()
        {
            var doc = new XmlDocument();
            XmlNodeBase target = new XmlNodeBase();
            XmlElement expected = doc.CreateElement("test");
            XmlElement actual;
            target.Extension = expected;
            actual = target.Extension;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for AnyOtherElements
        ///</summary>
        [TestMethod()]
        public void XmlNodeBase_AnyOtherElements_Test()
        {
            string expectedValue = "testElement";
            var document = new XmlDocument();
            XmlNodeBase target = new XmlNodeBase();
            target.AnyOtherElements.Add(document.CreateElement(expectedValue));
            Collection<XmlElement> actual;
            actual = target.AnyOtherElements;
            Assert.AreEqual(actual[0].Name, expectedValue);
        }

        /// <summary>
        ///A test for AnyOtherAttributes
        ///</summary>
        [TestMethod()]
        public void XmlNodeBase_AnyOtherAttributes_Test()
        {
            XmlNodeBase target = new XmlNodeBase();
            XmlAttribute actual;

            string attributeName = "testName";
            string attributeValue = "testValue";

            target.AddAttribute(attributeName, attributeValue);
            actual = target.AnyOtherAttributes[attributeName];

            Assert.AreEqual(attributeValue, actual.Value);
        }

        /// <summary>
        ///A test for AddAttribute
        ///</summary>
        [TestMethod()]
        public void XmlNodeBase_Add_Attribute_Test()
        {
            XmlNodeBase target = new XmlNodeBase();
            string attributeName = "testAttribute";
            string attributeValue = "testValue";
            target.AddAttribute(attributeName, attributeValue);
            Assert.AreEqual(target.AnyOtherAttributes[0].LocalName, attributeName);
            Assert.AreEqual(target.AnyOtherAttributes[0].Value, attributeValue);
        }

        /// <summary>
        ///A test for XmlNodeBase Constructor
        ///</summary>
        [TestMethod()]
        public void XmlNodeBaseConstructorTest()
        {
            XmlNodeBase target = new XmlNodeBase();
            Assert.IsNotNull(target);
        }
    }
}
